﻿/*
 * Cratos Tools - General
 * Cratos Data Object Interface declaration
 * 
 * Copyright (c) 2011-2012 Draco
 * 
 * This file is part of Cratos.
 * 
 * Cratos is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Cratos is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cratos.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *       .==.        .==.
 *      //'^\\      //^'\\
 *     // ^ ^\(\__/)/^ ^^\\
 *    //^ ^^ ^/6  6\ ^^ ^ \\
 *   //^ ^^ ^/( .. )\^ ^ ^ \\
 *  // ^^ ^/\| V""V|/\^ ^ ^ \\
 * //^^/\/ /  '~~'  \ \/\^ ^ \\
 *  ------------------------------------
 *  HERE BE DRAGONS
 *  
 *  Johan Dercksen - johan@draco.co.za
 */
using System;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Cratos.Tools.General
{
	/// <summary>
	/// Cratos Data Object Interface declaration
	/// </summary>
	public interface IDOCratos : ICloneable
	{
		#region Interface Events
		#endregion

		#region Interface Properties
		/// <summary>
		/// Data Object GUID
		/// </summary>
		Guid DOGuid { get; set; }

		/// <summary>
		/// Ignore Unity Indicator
		/// </summary>
		bool IgnoreUnity { get; set; }

		/// <summary>
		/// Changed Indicator
		/// </summary>
		bool IsChanged { get; set; }

		/// <summary>
		/// Loading indicator
		/// </summary>
		bool IsLoading { get; set; }

		/// <summary>
		/// Loaded indicator
		/// </summary>
		bool IsLoaded { get; set; }

		/// <summary>
		/// Cratos Data Object Action
		/// </summary>
		DOCratosAction DOAction { get; set; }

		/// <summary>
		/// Cratos Data Object Action Result
		/// </summary>
		DOCratosActionResult DOActionResult { get; set; }

		/// <summary>
		/// Cratos Data Object Custom Action name
		/// </summary>
		string DOCustomActionName { get; set; }

		/// <summary>
		/// Database Connection Name
		/// </summary>
		string DBConnectionName { get; set; }

		/// <summary>
		/// Cratos Command Type
		/// </summary>
		DOCratosActionType DBActionType { get; set; }

		/// <summary>
		/// Collection of Errors
		/// </summary>
		Collection<CratosError> Errors { get; }

		/// <summary>
		/// Cratos Data Object Actions
		/// </summary>
		Collection<DOCratosActionAttribute> AllDOActions { get; }

		/// <summary>
		/// All Cratos Data Object Column Properties
		/// </summary>
		Collection<DOCratosColumnAttribute> AllDOColumns { get; }

		/// <summary>
		/// Cratos Data Object Collection Filter Columns
		/// </summary>
		Collection<DOCratosCollectionFilterAttribute> AllDOCollectionFilters { get; }

		/// <summary>
		/// All Cratos Embedded Data Object Column Properties
		/// </summary>
		Collection<DOCratosEmbeddedAttribute> AllDOEmbedded { get; }

		/// <summary>
		/// All Data Object Properties
		/// </summary>
		Collection<PropertyInfo> AllDOProperties { get; }

		#region Action indicators
		/// <summary>
		/// Can Create indicator
		/// </summary>
		bool CanCreate { get; }

		/// <summary>
		/// Can Retrieve indicator
		/// </summary>
		bool CanRetrieve { get; }

		/// <summary>
		/// Can Update indicator
		/// </summary>
		bool CanUpdate { get; }

		/// <summary>
		/// Can Delete indicator
		/// </summary>
		bool CanDelete { get; }
		#endregion

		/// <summary>
		/// Error Message
		/// </summary>
		string ErrorMessage { get; }
		#endregion

		#region Interface Methods
		/// <summary>
		/// Reset all variables to their default values
		/// </summary>
		void Clear();

		/// <summary>
		/// Initialize the DO Rules
		/// </summary>
		void InitializeRules();

		/// <summary>
		/// Add Custom Rule to Data Object Validation
		/// </summary>
		/// <param name="doAction">Cratos Action</param>
		/// <param name="newRule">New Cratos Rule</param>
		void AddRule(DOCratosAction doAction, CratosRule newRule);

		/// <summary>
		/// Validate the object against the current action
		/// </summary>
		/// <returns>A boolean indicating the success of the method</returns>
		bool Validate();

		/// <summary>
		/// Validate all the relevant Rules
		/// </summary>
		/// <param name="doAction">Cratos Action</param>
		/// <returns>A boolean indicating the success of the method</returns>
		bool ValidateRules(DOCratosAction doAction);

		/// <summary>
		/// Perform the specified Action
		/// </summary>
		/// <returns>A boolean indicating the success of the method</returns>
		bool PerformAction();

		/// <summary>
		/// Load the Embedded data
		/// </summary>
		/// <param name="doProperty">Data Object Property</param>
		/// <param name="doCratos">Cratos Data Object</param>
		/// <returns>A boolean indicating the success of the method</returns>
		bool LoadEmbedded(string doProperty, IDOCratos doCratos);

		/// <summary>
		/// Display the current Errors in the error collection
		/// </summary>
		/// <param name="appTitle">Application Title</param>
		void DisplayError(string appTitle);

		/// <summary>
		/// Compare To method
		/// </summary>
		/// <param name="compareObj">Object to be compared to</param>
		/// <returns>A value that indicates the relative order of the objects being compared</returns>
		int CompareTo(object compareObj);

		/// <summary>
		/// Create Serialize Stream from object
		/// </summary>
		/// <returns>
		/// A byte array of the serialized object
		/// </returns>
		byte[] CreateSerializeStream();

		/// <summary>
		/// Create Object from a Serialized object
		/// </summary>
		/// <param name="objectStream">A byte array representing the serialized object</param>
		/// <returns>
		/// The recreated object
		/// </returns>
		IDOCratos CreateObjectFromStream(byte[] objectStream);
		#endregion
	}
}
